

class Solution:
    def lengthOfLongestSubstring(self, s: str) -> int:
        lst=[]
        m=0
        for i in range(len(s)):
            if s[i] in lst:
                m=max(m,len(lst))
                n = lst.index(s[i])
                lst = lst[n+1:]
            lst.append(s[i])
        m = max(m, len(lst))
        return m



if __name__ == '__main__':
    s = Solution()
    print(s.lengthOfLongestSubstring("abcabcbb"))
